//
//  ByCellWithdrawInfo.m
//  chequanbao_ios
//
//  Created by mc on 2017/7/7.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByCellWithdrawInfo.h"

@interface ByCellWithdrawInfo ()<UITextFieldDelegate>
@property (nonatomic, copy) NSString *title;
@property (nonatomic, assign) NSInteger section;
@end

@implementation ByCellWithdrawInfo

+ (instancetype)cellWithTableView:(UITableView*)tableView title:(NSString *)title section:(NSInteger)section{
    
    static NSString *cellIdentifier = @"ByCellWithdrawInfo";
    ByCellWithdrawInfo *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier title:title section:section];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier title:(NSString *)title section:(NSInteger)section{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        self.backgroundColor = [UIColor clearColor];
        _title = title;
        _section = section;
        [self createViews];
    }
    return self;
}

- (void)createViews{
    CGFloat x,y,width,height;
    x = 10;
    y = 0;
    height = 50;
    width = SCREEN_WIDTH - 20;
    UIView *bgview = [[UIView alloc] initWithFrame:CGRectMake(x, y, width,height )];
    bgview.backgroundColor = [UIColor colorWithWhite:0.95 alpha:0.25];
    bgview.layer.cornerRadius = 4.0;
    [self addSubview:bgview];
    
    // 标题
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 10, [@"收款账户开户网点" getSizeOfString:14].width, 30)];
    titleLabel.font = FONT(14);
    titleLabel.textColor = [UIColor colorWithWhite:0.90 alpha:1];
    titleLabel.text = _title;
    [self addSubview:titleLabel];
    
    // 输入框
    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(titleLabel.right + 20, 10, SCREEN_WIDTH - titleLabel.right - 20 - 20, 30)];
    tf.tag = 10 + _section;
    tf.textColor = [UIColor whiteColor];
    tf.delegate = self;
    [self addSubview:tf];
    
    if ([_title isEqualToString:@"提现金额"]) {
        tf.keyboardType = UIKeyboardTypeNumberPad;
    }


}

-(void)textFieldDidEndEditing:(UITextField *)textField{
    if (self.editTextBlock) {
        NSDictionary *dic = @{@"section":@(_section),@"value":textField.text};
        self.editTextBlock(dic);
    }
}
@end
